package com.alongstudio.account.action.base;

import com.alongstudio.account.commons.exception.BusinessException;
import com.alongstudio.account.constants.SystemConstant;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public abstract class BaseAction extends ActionSupport {
	private String OPERATOR_RESULT;// 返回提示结果
	public Integer start;//分页参数
	public Integer total;//条件查询结果总数
	public Integer pageSize;	//分页参数
	private String className=BaseAction.class.getName();
	
	public abstract String executeAction() throws BusinessException;
	@Override
	public String execute() throws Exception {
		try{
			executeAction();
		}
		catch(BusinessException e){
			throw e;
		}
		catch(Exception e){
			throw new BusinessException(className, e);
		}
		return SUCCESS;
	}
	
	
	public Integer getStart() {
		return start;
	}
	public void setStart(Integer start) {
		this.start = start;
	}
	public Integer getTotal() {
		return total;
	}
	public void setTotal(Integer total) {
		this.total = total;
	}
	public Integer getPageSize() {
		return pageSize;
	}
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}
	
	public String getOPERATOR_RESULT() {
		return OPERATOR_RESULT;
	}
	public void setOPERATOR_RESULT(String oPERATOR_RESULT) {
		OPERATOR_RESULT = oPERATOR_RESULT;
	}
	/**
	 * 当前登录用户的id
	 * @return
	 */
	protected String getCurrentClientUserId(){
		return (String)getSessionAttribute(SystemConstant.SESSION_USER_ID);
	}
	/**
	 *  将参数保存在session中
	 * @param key
	 * @param obj
	 */
    protected void setSessionAttribute(String key, Object obj) {
    	ActionContext.getContext().getSession().put(key, obj);
    }
    /**
     * 取得Session中的参数
     * @param key
     * @return
     */
    protected Object getSessionAttribute(String key){
    	return ActionContext.getContext().getSession().get(key);
    }
    
}
